<?php
/**
 * Account API
 *
 * Provides access and CRUD mechanism for accounts.
 *
 * @author Terence Yan <terence.yan@me.com>
 */
 
require_once(__DIR__.'/CommonClass/errorcode.php');
require_once(__DIR__.'/account.controller.php');

/**
 * Read account
 * @param $userName account id
 * @param $authUserName user authorizing the api call
 * @param $authPasswordHashuser authorizing password.
 * @return array success code, user string, hash string.
 */
function getAccount($username, $authUsername, $authPass) {
    if (empty($username)){
        return array(ErrorCode::failRead + 100);
    }
    if (empty($authUsername)) {
        return array(ErrorCode::failRead + 200);
    }
    if (empty($authPass)) {
        return array(ErrorCode::failRead + 300);
    }

    $controller = new AccountController();

    if(!($controller -> authenticateValidator($authUsername, $authPass))){
        return array(ErrorCode::authFailRead);
    }
    return $controller ->requestHandler(array(
        ':accName' => $username
        )
    );
}

?>